import org.junit.Assert;
import org.junit.Test;
import carts.addition.PrisingType;

import java.math.BigDecimal;

public class PointOfSaleTerminalTest {

    @Test
    public void testFirstCase() throws Exception {
        PointOfSaleTerminal terminal = new PointOfSaleTerminal();
        terminal.setPricing(PrisingType.LIBERAL);
        terminal.scan("A");
        terminal.scan("B");
        terminal.scan("C");
        terminal.scan("D");
        terminal.scan("A");
        terminal.scan("B");
        terminal.scan("A");
        BigDecimal result = terminal.calculateTotal();

        Assert.assertEquals(BigDecimal.valueOf(13.25), result);
    }

    @Test
    public void testSecondCase() throws Exception {
        PointOfSaleTerminal terminal = new PointOfSaleTerminal();
        terminal.setPricing(PrisingType.LIBERAL);
        for (int i = 0; i < 7; i++) {
            terminal.scan("C");
        }
        BigDecimal result = terminal.calculateTotal();

        Assert.assertEquals(BigDecimal.valueOf(6.00), result);
    }

    @Test
    public void testThirdCase() throws Exception {
        PointOfSaleTerminal terminal = new PointOfSaleTerminal();
        terminal.setPricing(PrisingType.LIBERAL);
        terminal.scan("A");
        terminal.scan("B");
        terminal.scan("C");
        terminal.scan("D");
        BigDecimal result = terminal.calculateTotal();

        Assert.assertEquals(BigDecimal.valueOf(7.25), result);
    }
}
